package com.intelligent.ispc.utils;

/**
 * Created by Rovey.Luo on 2015/11/14.
 */
public enum RoleEnable {
    ENABLE(1, "Enable"),
    DISABLE(2, "Disable");

    private int index;
    private String code;

    RoleEnable(int index, String code) {
        this.code = code;
        this.index = index;
    }

    public static RoleEnable getValueOf(String code) {
        if (ENABLE.getCode().equals(code)) {
            return ENABLE;
        } else if (DISABLE.getCode().equals(code)) {
            return DISABLE;
        } else {
            return null;
        }
    }

    public static RoleEnable getValueOf(int index) {
        switch (index) {
            case 1:
                return ENABLE;
            case 2:
                return DISABLE;
            default:
                return null;
        }
    }

    public String getCode() {
        return code;
    }

    public int getIndex() {
        return index;
    }
}
